package Projekt;

import java.awt.*;
import java.awt.geom.Line2D;

/**
 * 
 * Linienklasse zur Erstellung einer Line zwischen zwei gegebener Punkte
 *
 */
public class Line extends Line2D.Double implements Paintable {
	
	private static final long serialVersionUID = 1L;
	Point point1 = new Point(),
		  point2 = new Point();
	Color color;

	
	public Line(){
		super();
	}
	
	public Line(Point p1, Point p2, Color color) {
		this.point1 = p1;
		this.point2 = p2;
		this.color = color;
		
	}
	public Line(int p1x, int p1y, int p2x, int p2y, Color color){
		this.point1.x = p1x;
		this.point1.y = p1y;
		this.point2.x = p2x;
		this.point2.y = p2y;
		this.color = color;
	}
	public void setCol(Color color) {
		this.color = color;
	}

	public void setP2(Point point2) {
		this.point2 = point2;
	}
	
	public void setP1(Point point1) {
		this.point1 = point1;
		
	}

	public void painting(Graphics2D g2D, boolean stroke) {
		BasicStroke basic;
		float[] dash = {8.0f,3.0f};  //fuer gestrichelte Linie
		g2D.setPaint(color);
		if (stroke)
			basic = new BasicStroke(1.0f,BasicStroke.CAP_BUTT,
					BasicStroke.JOIN_BEVEL,10.0f,dash,0.0f);
		else basic = new BasicStroke(1.0f);
		g2D.setStroke(basic);
		g2D.drawLine(point1.x,point1.y,point2.x,point2.y);
	}
}
